<template>
  <!-- 策略分案数据查询 -->
  <section class="page outsource-performance-query">
    <data-form :model="searchModel" @onSearch="refreshData" :page="pageService" >
      <template slot="inputs">
        <el-form-item label="受托方" prop="strategyName">
          <el-input v-model="searchModel.strategyName"></el-input>
        </el-form-item>   
        <el-form-item label="委外催收员用户名" prop="departmentType">
        <el-select v-model="searchModel.departmentType" placeholder="请选择" clearable>
         <el-option v-for="{index,name,code} in $dict.getDictData('DepartmentType')" :key="index" :label="name" :value="code"></el-option>
        </el-select>
       </el-form-item>
         <el-form-item label="委外日期" prop="distributeDate">
          <el-date-picker type="daterange" :editable="false" v-model="searchModel.distributeDate" placeholder="选择日期时间" clearable>
          </el-date-picker>
        </el-form-item>
      </template>
    </data-form>

    <data-box :data="dataSet" @onPageChange="refreshData" :page="pageService">
        <template slot="columns">
        <!--数据列区域-->
        <el-table-column prop="caseNumber" label="受托方" :min-width="$helper.getColumnWidth(7)" show-overflow-tooltip></el-table-column>
        <el-table-column prop="distributeDate" label="委外催收员用户名" :formatter="(row) => $filter.dateTimeFormat(row.distributeDate)" :min-width="$helper.getColumnWidth(7)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="overdueAmount" label="排名" :min-width="$helper.getColumnWidth(5)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="overduePeriod" label="日期" :min-width="$helper.getColumnWidth(3)">
        </el-table-column>
        <el-table-column prop="overDueDays" label="回收金额" :min-width="$helper.getColumnWidth(7)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="strategyName" label="回款率" :min-width="$helper.getColumnWidth(7)" show-overflow-tooltip></el-table-column>          
        <el-table-column prop="departmentType" label="委外总金额" :min-width="$helper.getColumnWidth(7)" show-overflow-tooltip>
            <template slot-scope='scope'>
                <span>{{scope.row.departmentType | dictConvert('DepartmentType')}}</span>
            </template>
        </el-table-column>      
        </template>
    </data-box>
  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Auth, Layout, Dependencies } from "~/core/decorator";
import { PageService } from "~/utils/page.service";
import DataForm from "~/components/common/data-form.vue";
import DataBox from "~/components/common/data-box.vue";
import { SortService } from "~/utils/sort.service";
import NumberRange from "~/components/common/number-range.vue";
import { SynthesizeQueryService } from "~/services/domain-service/synthesize-query.service";
import { namespace, Getter, Mutation } from "vuex-class";

@Layout("workspace")
@Component({
  components: {
    DataForm,
    DataBox,
    NumberRange
  }
})
export default class OutsourcePerformanceQuery extends Vue {

  @Dependencies(PageService) private pageService: PageService;

  @Dependencies(SortService) private sortService: SortService;

  @Dependencies(SynthesizeQueryService)
  private synthesizeQueryService: SynthesizeQueryService;

  private searchModel: any = {
    strategyName: "",
    departmentType: "",
    distributeDate: []
  };

  private dataSet: any[] = [];

  private refreshData() {
    this.synthesizeQueryService
      .queryCaseDistributeData(this.searchModel, this.pageService)
      .subscribe(data => {
        this.dataSet = data
        if(this.dataSet){
          this.dataSet.forEach(x=>{
            x.overduePeriod>12?x.overduePeriod = 'M12+':x.overduePeriod = 'M'+x.overduePeriod
          })
        }
      });
  }

  private mounted() {
    this.refreshData();
  }
}
</script>
<style lang="less">
</style>
